WARNING: this page is considered obsolete, as it contains information about old CHICKEN versions.

bash completion for chicken tools

The Debian bash package features support for command line completion through the file /etc/bash_completion. This page of the chicken wiki provides a file to add completion for the chicken tools in bash.

Currently, only chicken-setup is supported. Hopefully csi and csc will follow.

CHICKEN 4 is currently not supported.

Use

Copy the following code in a file named chicken in /etc/bash_completion.d. Alternatively, source it after /etc/bash_completion (which is sourced from ~/.bashrc or elsewhere).

# chicken-setup command line completion for bash.
#
# version 0.2 -- 2007.01.13 -- vo minh thu
#  - chicken-setup <tab> completes for *.egg files.
# version 0.1 -- 2007.01.13 -- vo minh thu

_chicken_setup()
{
    local cur prev frst opts
    COMPREPLY=()
    cur=${COMP_WORDS[COMP_CWORD]}
    prev=${COMP_WORDS[COMP_CWORD-1]}
    frst=${COMP_WORDS[1]}

    opts='-help -version -repository -program-path -host \
          -uninstall -list -run -script -eval -verbose \
          -keep -csc-option -dont-ask -no-install -docindex \
          -check -test -ls -fetch-tree -tree -svn -revision \
          -local -destdir'

    paroptions=${opts}

    # the following options take zero or one argument
    case "${prev}" in
    '-repository' | '-program-path' | '-local' | '-destdir' )
        COMPREPLY=( $(compgen -A directory ${cur}) )
        return 0;;
    '-host' )
        COMPREPLY=( $(compgen -A hostname ${cur}) )
        return 0;;
    '-run' | '-script' | '-tree' )
        COMPREPLY=( $(compgen -A file ${cur}) )
        return 0;;
    '-uninstall' | '-ls' )
        local exts=$( chicken-setup -list | awk '{ print $1 }' )
        COMPREPLY=( $(compgen -W "${exts}" -- ${cur}) )
        return 0;;
    esac

    # the following options take zero or more arguments
    case "${frst}" in
    '-list' | '-test' )
        local exts=$( chicken-setup -list | awk '{ print $1 }' )
        COMPREPLY=( $(compgen -W "${exts}" -- ${cur}) )
        return 0;;
    esac

    case ${cur} in
    -* )
        COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
        return 0;;
    * )
        COMPREPLY=($(compgen -f -X "egg" -- ${cur}))
    esac

}
[ "$have" ] && complete -F _chicken_setup chicken-setup